export function get(o) {
	return new Promise(function(resolve, reject) {
		{
			uni.showLoading({
				title: '加载中'
			})
			uni.request({
				url: global.baseUrl + o.url + '?apikey=' + global.apikey,
				data: o.data,
				header: {

				},
				success: (res) => {
					uni.hideLoading()
					resolve(res)
				},
				fail: (error) => {
					uni.hideLoading()
					reject(error)
				}
			});
		}
	})
}

export function post(o) {
	return new Promise(function(resolve, reject) {
		{
			uni.showLoading({
				 title: '加载中'
			})
			uni.request({
				url: global.baseUrl + o.url + '?apikey=' + global.apikey,
				data: o.data,
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				method: 'POST',
				success: (res) => {
					uni.hideLoading()
					resolve(res)
				},
				fail: (error) => {
					uni.hideLoading()
					reject(error)
				}
			});
		}
	})
}

// 不需要apikey的请求
export function postNoApiKey(o) {

}

// 用户登录需要的唯一标识
export function getUnionid() {
	// 以当前时间作为唯一标识
	var timestamp = (new Date()).getTime();
	return timestamp

}


